package com.nanfeng.screenshot.enums;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * @ClassName：ChengduHousingEnum
 * @Author: LiuYunZhao
 * @Date: 2025/7/11 9:01
 * @Description: 访问的地址 https://docs.qq.com/doc/DUGhCQ0N0UVNnSWtG
 */
public enum ChengduHousingEnum {
    // 枚举元素列表（包含序号属性，按原顺序从1开始）
   /* BAI_DU(1, "https://www.baidu.com", "百度.jpg", "百度"),
    BI_YING(2, "https://www.bing.com", "必应.jpg", "必应"),
    WANG_YI(3, "https://www.163.com", "网易.jpg", "网易"),*/

    OFFICIAL_WEBSITE(1, "http://cdzj.chengdu.gov.cn/", "住建官网.jpg", "住建官网"),
    RONG_E_BAN(2, "https://www.cdzjryb.com/", "住建蓉e办.jpg", "住建蓉e办"),
    TALENT_ACCOMMODATION(3, "http://cdzj.chengdu.gov.cn/cdzj/rcaj/RCAJ.shtml", "人才安居.jpg", "人才安居"),
    LEGAL_PERSON_SERVICE(4, "https://www.cdzjryb.com/FRFW/Default.aspx", "主题服务-法人服务.jpg", "主题服务-法人服务"),
    PERSONAL_SERVICE(5, "https://www.cdzjryb.com/GRZX/Default.aspx", "主题服务-个人服务.jpg", "主题服务-个人服务"),
    PUBLIC_NOTICE(6, "http://cdzj.chengdu.gov.cn/cdzj/c131969/nav_list.shtml", "公示公告.jpg", "公示公告"),
    NOTICE_BULLETIN(7, "http://cdzj.chengdu.gov.cn/cdzj/c150805/list.shtml", "通知通报.jpg", "通知通报"),
    POLICY_DOCUMENTS(8, "http://cdzj.chengdu.gov.cn/cdzj/c150804/zcwj.shtml", "政策文件.jpg", "政策文件"),
    CREDIT_INQUIRY(9, "https://pt.cdzjryb.com:8145/", "信用查询.jpg", "信用查询"),
    HOUSE_PURCHASE_SYSTEM(10, "https://zw.cdzjryb.com/lottery/accept/index", "购房系统.jpg", "购房系统"),
    PERSONAL_LOGIN(11, "https://zw.cdzjryb.com/publicCAS/citizenPerson/login", "个人登录.jpg", "个人登录 "),
    ENTERPRISE_LOGIN(12, "https://pt.cdzjryb.com/qy/QyLogin.aspx", "企业登录.jpg", "企业登录"),
    ADMIN_SERVICE_SYSTEM(13, "https://pt.cdzjryb.com/login.aspx?ReturnUrl=http%3a%2f%2fpt.cdzjryb.com%2fdefault.aspx", "行政服务应用系统.jpg", "行政服务应用系统"),

    INDIVIDUAL_WECHAT(15, "https://jcfw.cdzjryb.com/funi-wx-cdfg/navigation/goWfgGrHome", "成都住建微政务个人-1.jpg", "成都住建微政务个人"),
    ENTERPRISE_WECHAT(16, "https://jcfw.cdzjryb.com/funi-wx-cdfg/navigation/goWfgQyHome", "成都住建微政务企业-1.jpg", "成都住建微政务企业"),
    ALL_LIFE_INDEX(17, "https://blmp.cdzjryb.com/", "全生命周期主页.jpg", "全生命周期主页"),
    ALL_LIFE_INDEX_E(18, "https://blmp.cdzjryb.com/fplc_daas_portal/#/rybIndex", "全生命周期蓉e办.jpg", "全生命周期蓉e办"),
    ALL_LIFE_SERVICE_HALL(19, "https://blmp.cdzjryb.com/service-hall", "全生命周期办事大厅.jpg", "全生命周期办事大厅"),
    RENT(20, "https://zw.cdzjryb.com/rent/#/main/index", "租赁系统.jpg", "租赁系统"),
    ;

    // 枚举属性（新增序号）
    private final int serialNumber;
    private final String url;
    private final String fileName;
    private final String note;

    // 构造方法（添加序号参数）
    ChengduHousingEnum(int serialNumber, String url, String fileName, String note) {
        this.serialNumber = serialNumber;
        this.url = url;
        this.fileName = fileName;
        this.note = note;
    }

    // getter方法
    public int getSerialNumber() {
        return serialNumber;
    }

    public String getUrl() {
        return url;
    }

    public String getFileName() {
        return fileName;
    }

    public String getNote() {
        return note;
    }

    // 获取所有枚举元素的list方法
    public static List<ChengduHousingEnum> list() {
        List<ChengduHousingEnum> list = new ArrayList<>();
        for (ChengduHousingEnum item : values()) {
            list.add(item);
        }
        return list;
    }

    // 根据序号查询URL
    public static String getUrlBySerialNumber(int serialNumber) {
        return getBySerialNumber(serialNumber)
                .map(ChengduHousingEnum::getUrl)
                .orElse(null);
    }

    // 根据序号查询fileName
    public static String getFileNameBySerialNumber(int serialNumber) {
        return getBySerialNumber(serialNumber)
                .map(ChengduHousingEnum::getFileName)
                .orElse(null);
    }

    // 根据序号查询note
    public static String getNoteBySerialNumber(int serialNumber) {
        return getBySerialNumber(serialNumber)
                .map(ChengduHousingEnum::getNote)
                .orElse(null);
    }

    // 内部工具方法：根据序号获取枚举实例
    private static Optional<ChengduHousingEnum> getBySerialNumber(int serialNumber) {
        for (ChengduHousingEnum item : values()) {
            if (item.serialNumber == serialNumber) {
                return Optional.of(item);
            }
        }
        return Optional.empty();
    }
}